package util;

import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class AnotherFont {
	
	private static Typeface typefaceNormal;
	
	private static Typeface typefaceBold;
	
	public static final void findTypeface(ViewGroup parentView){
		
		typefaceNormal = Typeface.createFromAsset(parentView.getResources().getAssets(), "HelveticaNeue.ttf");
		typefaceBold = Typeface.createFromAsset(parentView.getResources().getAssets(), "HelveticaNeueBold.ttf");
		if (parentView != null && parentView.getChildCount() > 0){
			for (int i = 0; i< parentView.getChildCount(); i++){
				View v = parentView.getChildAt(i);
				if (v instanceof TextView){
					changeTypeface((TextView)v);
				} else if (v instanceof ViewGroup){
					findTypeface((ViewGroup)v);
				}
			}
		}
	}
	
	static void changeTypeface (TextView view){
//		Log.i("---------", "Change text " + view.getText());
		if (view.getTypeface() != null && view.getTypeface().isBold()){
			view.setTypeface(typefaceBold);
		} else {
			view.setTypeface(typefaceNormal);
		}
				
	}

}
